package com.iflytek.ssm.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {

    // 定义正则表达式模式
    private static final String PASSWORD_PATTERN = "^(?=.*[a-z])(?=.*[A-Z])|(?=.*\\d)(?=.*[a-zA-Z]).{6}$";

    /**
     * 校验密码是否符合要求
     *
     * @param password 要校验的密码
     * @return 如果密码符合要求返回true，否则返回false
     */
    public static boolean cheackPwd(String password) {
        Pattern pattern = Pattern.compile(PASSWORD_PATTERN);
        Matcher matcher = pattern.matcher(password);
        return matcher.matches();
    }

    public static void main(String[] args) {
        // 测试密码校验工具类
        String[] testPasswords = {"abc123", "ABCDEF", "abcdef", "123456", "Abc123", "aBc123"};

        for (String password : testPasswords) {
            System.out.println("密码: " + password + " 是否满足要求: " + cheackPwd(password));
        }
    }

}
